﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Data.SqlServerCe;

namespace AlumnesBD
{
    public partial class Form1 : Form
    {
        public DataGridViewForm f1;

        public Form1()
        {
            
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: esta línea de código carga datos en la tabla 'alumneDataSet.Alumne' Puede moverla o quitarla según sea necesario.
            //this.alumneTableAdapter.Fill(this.alumneDataSet.Alumne);

            SqlCeConnection con = new
               SqlCeConnection("Data Source=|DataDirectory|\\Database1.sdf");

            con.Open();

            SqlCeCommand com = new SqlCeCommand("SELECT * FROM Alumne", con);
            com.ExecuteReader();
            SqlCeDataReader r = com.ExecuteReader();

            while (r.Read())
            {
                //Creem FIla
                Object[] arr = new Object[2];
                arr[0] = r["Nom"];
                arr[1] = r["Cognoms"];

                dataGridView1.Rows.Add(arr);
            }

            

            


        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            this.f1 = new DataGridViewForm();
            f1.Show();

        }
    }
}
